package ink.feta.task.job.listener;

import org.apache.shardingsphere.elasticjob.infra.listener.ShardingContexts;
import org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class MyDistributeOnceJobListener extends AbstractDistributeOnceElasticJobListener {
    private static Logger logger = LoggerFactory.getLogger(MyDistributeOnceJobListener.class);
    private static final long startTimeoutMills = 3000;
    private static final long completeTimeoutMills = 3000;

    public MyDistributeOnceJobListener() {
        super(startTimeoutMills, completeTimeoutMills);
    }


    @Override
    public void doBeforeJobExecutedAtLastStarted(ShardingContexts shardingContexts) {
        logger.info("doBeforeJob [{}] ",shardingContexts.getJobName());
    }

    @Override
    public void doAfterJobExecutedAtLastCompleted(ShardingContexts shardingContexts) {
        logger.info("doAfterJob [{}] ",shardingContexts.getJobName());
    }

    @Override
    public String getType() {
        return "distributeOnceJobListener";
    }
}
